<?php
/**
 * Created by PhpStorm.
 * User: zhang
 * Date: 2016/2/28
 * Time: 9:36
 */

namespace Chealth\Model;

use Think\Model;

class ChealthDepartmentModel extends Model
{
    protected $_validate = array(
        array('name','require','部门名称必须填写!', 1, 'regex', 3),
    );

    public function editDepartment(){
        if($this->create()){
            if(empty($this->data['id'])){
                $res = $this->add();
            }else{
                $res = $this->save();
            }
            if($res === false){
                $this->error = '数据库错误,请重试';
                return false;
            }else{
                return true;
            }
        }else{
            return false;
        }
    }
}